const axios = require('../lib/axios/axios');

$authr()
require('../css/projectDes.less')

require('../font/iconfont.css')

// const videojs = require('../js/common/video.min.js');

document.ready(function () {

    let video = document.querySelector("#my-video");


    // 回退
    let back = document.querySelector('#back');

    back.addEventListener('click', function () {
        location.href = "./courseTrain.html"
    })


    let f = false
    // 开关
    let startVideo = document.querySelector('#startVideo');


    // 开始播放
    startVideo.addEventListener('click', function () {
        video.play()
        this.classList.add('none');
    })

    // 暂停
    video.addEventListener('pause', function () {
        f = false;
        startVideo.classList.remove('none')
    })

    // 正在播放
    video.addEventListener('playing', function () {
        f = true;
        if (!startVideo.className.includes("none")) {
            startVideo.classList.add('none')
        }
    })

    // 点击 切换开关
    video.addEventListener('click', function () {
        f ? video.pause() : video.play()
    })



    // 关注
    let smallBtn = document.querySelector('#smallBtn');
    smallBtn.addEventListener('click', function () {

        this.classList.add('attention');
        this.innerHTML = "已关注"

    })



    // 获取上一个页面穿过的数据

    let cid = location.search.split("=")[1]
    sessionStorage.setItem('cid', cid)
    // 通过课程id查找所有的课程
    axios.get(`${BASE_URL}/sports/courseDetail?id=${cid}`).then(result => {

        result = result.data.data
        console.log(result);
        document.querySelector('#karloli').innerHTML = result.calorie
        document.querySelector('#allTime').innerHTML = result.time
        document.querySelector('#usePerson').innerHTML = result.peoplenum
        document.querySelector('#desc').innerHTML = result.desc
        document.querySelector('#titleName').innerHTML = result.name
        localStorage.setItem("currentData", JSON.stringify(result.fragments))

    }).catch(r => {
        console.log(r);
        console.log("cw");
    })





















})